<!-- Search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  (onSearch)="queryData($event)"
  (onReset)="resetData($event)"
>
</app-search-bar>

<nz-card class="m-t-2">
  <div class="operation-wrap">
    <button nz-button nzType="primary" (click)="exportTable()">
      <i nz-icon nzType="download"></i>
      导出
    </button>
  </div>

  <div class="pagination-wrap-position table-wrap p-t-15">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="200px" nzLeft>订单编号</th>
          <th nzAlign="center" nzWidth="150px">订单状态</th>
          <th nzAlign="center" nzWidth="130px">用户身份</th>
          <th nzAlign="center" nzWidth="180px">机器编码</th>
          <th nzAlign="center" nzWidth="120px">单价</th>
          <th nzAlign="center" nzWidth="120px">现金</th>
          <th nzAlign="center" nzWidth="120px">爱豆</th>
          <th nzAlign="center" nzWidth="120px">回收价</th>
          <th nzAlign="center" nzWidth="160px">物流信息</th>
          <th nzAlign="center" nzWidth="120px">退款金额</th>
          <th nzAlign="center" nzWidth="120px">返还爱豆</th>
          <th nzAlign="center" nzWidth="170px">下单时间</th>
          <th nzAlign="center" nzWidth="170px">付款时间</th>
          <th nzAlign="center" nzWidth="170px">发货时间</th>
          <th nzAlign="center" nzWidth="170px">收货时间</th>
          <th nzAlign="center" nzWidth="170px">货主</th>
          <th nzAlign="center" nzWidth="180px">交易流水</th>
          <th nzAlign="center" nzWidth="120px">子订单数量</th>
          <th nzAlign="center" nzWidth="200px">父订单编号</th>
          <th nzAlign="center" nzWidth="160px" nzRight>操作</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- 订单编号 -->
          <td nzAlign="center" nzLeft>{{ data.orderNum || '-' }}</td>
          <!-- 订单状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': orderNameFilter(data.status, 'color')}">
              {{ orderNameFilter(data.status, 'text') }}
            </span>
          </td>
          <!-- 用户身份 -->
          <td nzAlign="center">
            <ng-container [ngSwitch]="data.userType">
              <nz-tag *ngSwitchCase="1" [nzColor]="'#87d068'">C端</nz-tag>
              <nz-tag *ngSwitchCase="2" [nzColor]="'#2db7f5'">B端</nz-tag>
            </ng-container>
          </td>
          <!-- 机器编码 -->
          <td nzAlign="center">{{ data.equipmentCode || '-' }}</td>
          <!-- 单价 -->
          <td nzAlign="center">{{ data.price || '0' }}</td>
          <!-- 现金 -->
          <td nzAlign="center">{{ data.realPrice || '0' }}</td>
          <!-- 爱豆 -->
          <td nzAlign="center">{{ data.aiDouAmount || '0' }}</td>
          <!-- 回收价 -->
          <td nzAlign="center">
            {{ (data.realValuation || 0) + (data.aprc || 0) + (data.cprc || 0) }}
          </td>
          <!-- 物流信息 -->
          <td nzAlign="center">
            <p>{{ data.expressName || '-' }}</p>
            <p>{{ data.expressNum || '-' }}</p>
          </td>
          <!-- 退款金额 -->
          <td nzAlign="center">{{ data.refundPrice || '0' }}</td>
          <!-- 返还爱豆 -->
          <td nzAlign="center">{{ data.refundAiDouAmount || '0' }}</td>
          <!-- 下单时间 -->
          <td nzAlign="center">{{ data.createTime || '-' }}</td>
          <!-- 付款时间 -->
          <td nzAlign="center">{{ data.payTime || '-' }}</td>
          <!-- 发货时间 -->
          <td nzAlign="center">{{ data.shipTime || '-' }}</td>
          <!-- 收货时间 -->
          <td nzAlign="center">{{ data.receiptTime || '-' }}</td>
          <!-- 货主 -->
          <td nzAlign="center">{{ data.supplierName || '-' }}</td>
          <!-- 交易流水 -->
          <td nzAlign="center">{{ data.payOrderNum || '-' }}</td>
          <!-- 子订单数量 -->
          <td nzAlign="center">{{ data.childCount || '0' }}</td>
          <!-- 父订单编号 -->
          <td nzAlign="center">{{ data.parentOrderNum || '-' }}</td>
          <!-- 操作 -->
          <td nzAlign="center" nzRight>
            <a
              nz-button
              nzType="link"
              target="_blank"
              [routerLink]="['/used-store/usedOrderDetails']"
              [queryParams]="{ id: data.id }"
            >
              详情
            </a>
            <a nz-button nzType="link" (click)="followModal(data)">跟进</a>
          </td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>

<!-- 跟进Component -->
<app-follow-up #followUpRef [initParams]="initParams" [ohterParams]="{ type: 1 }"></app-follow-up>